//require
var ObjectID = require('mongodb').ObjectID;
var db =require('mongojs').connect("localhost:27017/test1",['user','seq']);

//insert
/*
db.seq.findAndModify({update:{$inc:{'id':1}},query:{'name':'user'}},function(err,seq){
	db.user.insert({'id':seq.id,'name':'baobao','age':20});
});
*/

//update
/*
db.user.update({'id':0},{$set:{'name':'xbl'}},function(err,updated){
	console.log(updated);
});
*/

//find;
/*
db.user.find(function(err,users){
	if(err){
		console.log("error:"+err);
		return ;
	}
	users.forEach(function(user){
		console.log(user);
	});
});
*/

//save and update
/*
db.user.save({id:2,name:'xbl2012',age:26,'_id': new ObjectID('4f30b123e488c71728000001')});
*/

//findOne
/*
db.user.findOne({id:2},function(err,user){
	console.log(user);
});
*/

//remove
/*
db.user.remove({id:2},function(err,removed){
	console.log(removed);
});
*/
